package net.huashitong.ssydt.provider.msg.service;


import net.huashitong.ssydt.base.dao.LongMapper;
import net.huashitong.ssydt.base.service.AbstractLongService;
import net.huashitong.ssydt.msg.entity.SsMsgUserMessage;
import net.huashitong.ssydt.msg.entity.vo.MessageReadInVO;
import net.huashitong.ssydt.provider.msg.mapper.SsMsgUserMessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.11.14
 */
@Service
@Transactional
public class SsMsgUserMessageServiceImpl extends AbstractLongService<SsMsgUserMessage> implements SsMsgUserMessageService {

    private SsMsgUserMessageMapper mapper;

    @Autowired
    public SsMsgUserMessageServiceImpl(SsMsgUserMessageMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    protected LongMapper<SsMsgUserMessage> getLongMapper() {
        return mapper;
    }

    @Override
    public int batchInsert(List<SsMsgUserMessage> ssMsgUserMessages) {
        return this.mapper.batchInsert(ssMsgUserMessages);
    }

    @Override
    public SsMsgUserMessage getByUserIdWithMessageId(String userId, Long messageId) {
        SsMsgUserMessage message = new SsMsgUserMessage();
        message.setUserId(userId);
        message.setMessageId(messageId);
        return this.mapper.getByUserIdWithMessageId(message);
    }

    @Override
    public int updateRead(MessageReadInVO messageReadInVO) {
        return this.mapper.updateRead(messageReadInVO);
    }


}
